﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TMDT.BusinessLogic;

namespace TMDT.Web.UI
{
    public partial class DangNhap : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                Response.Redirect("SanPham.aspx");
            }
        }

        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return;
            var service = new TaiKhoanManager();
            if (service.IsAccount(txtTenDangNhap.Text, txtMatKhau.Text))
            {
                Session["User"] = txtTenDangNhap.Text;
                Response.Redirect("SanPham.aspx");
            }
            else
            {
                lblError.Text = "Đăng nhập thất bại";
            }
        }
    }


}